#!/usr/bin/env ruby

# Run kafkat from source, specifically for testing stuff without doing a rake install.

require 'rubygems'
$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib') << File.join(File.dirname(__FILE__), 'addon')

require 'kafkat/version'
spec = Gem::Specification.load(File.join(File.dirname(__FILE__), 'kafkat.gemspec'))

# To avoid a warning about the version_requirements deprecation, we use this method inline.
def version_required(gem_def)
  return Gem::Dependency.instance_methods.map(&:to_sym).include?(:requirement) ? gem_def.requirement : gem_def.version_requirements
end
spec.dependencies.each do |dep|
  gem dep.name, version_required(dep) if dep.type == :runtime
end
Gem.loaded_specs['kafkat'] = spec # Prevents RubyGem from loading files from installed kafkat gems

require 'kafkat'
Kafkat::CLI.run!
